package com.itheima.controller;

import com.itheima.pojo.IndexPageVO;
import com.itheima.pojo.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.Date;

/***
 * 对应教材 P163-P171 增加了返回页面
 */
@Controller
public class UserController {
    @Autowired
    UserService userService;

    @RequestMapping("/loginUser")
    public String loginUser(IndexPageVO user, HttpSession httpSession){
        System.out.println(user);
        String url;
        httpSession.setAttribute("user", user);
        if (userService.isLucky(user)) {
            url = "input21";
        }
        else
            url="info";
        return url;
    }

}

